<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="lufylegend-1.10.0.js"></script>
</head>

<body>
<div id="mylegend">loading...</div>
<script>
init(50,"mylegend",320,480,main);
var loadinglayer,backlayer,background,stagelayer,stageSpeed;
var imglist={};
var imgdata=new Array({name:"xk", path:"xk.jpg"},{name:"flip",path:"flip.png"},{name:"thorn",path:"thorn.png"},{name:"left",path:"left.png"},{name:"player",path:"player.png"},{name:"right",path:"right.png"});
function main(){
	backlayer=new LSprite();
	backlayer.graphics.drawRect(1,"#000000",[0,0,320,480],true,"#000000");
	addChild(backlayer);
	loadinglayer=new LoadingSample6();
	backlayer.addChild(loadinglayer);
	LLoadManage.load(
		imgdata,
		function(progress){
			loadinglayer.setProgress(progress);	
		},
		gameInit
	);
}
function gameInit(result){
	imglist=result;
	backlayer.removeChild(loadinglayer);
	loadinglayer=null;
	var title=new LTextField();
	title.x=40;
	title.y=100;	
	title.size=30;
	title.color="#ffffff";
	title.text="是男人就下一百层";
	backlayer.addChild(title);
	backlayer.graphics.drawRect(1,"#ffffff",[50,240,220,40]);
	var textclick=new LTextField();
	textclick.size=18;
	textclick.color="#ffffff";
	textclick.text="点击页面开始游戏";
	textclick.x=(LGlobal.width-textclick.getWidth())/2;
	textclick.y=250;
	backlayer.addChild(textclick);
	backlayer.addEventListener(LMouseEvent.MOUSE_UP,gamestart);
}
function gamestart(){
	//清空背景
	backlayer.die();
	backlayer.removeAllChild();	
	background=new background();
	backlayer.addChild(background);
	stageInit();
	backlayer.addEventListener(LEvent.ENTER_FRAME,onframe);
}
function background(){
	base(this,LSprite,[]);	
	var self=this;
	self.bitmapData=new LBitmapData(imglist["xk"]); 
	self.bitmap1=new LBitmap(self.bitmapData);
	self.addChild(self.bitmap1);
	self.bitmap2=new LBitmap(self.bitmapData);
	self.bitmap2.y=self.bitmap1.getHeight();
	self.addChild(self.bitmap2);
	self.bitmap3=new LBitmap(self.bitmapData);
	self.bitmap3.y=self.bitmap1.getHeight()*2;
	self.addChild(self.bitmap3);
}
background.prototype.run=function(){
	var self=this;
	self.bitmap1.y -= 2;	
	self.bitmap2.y -= 2;	
	self.bitmap3.y -= 2;	
	if(self.bitmap1.y< -self.bitmap1.getHeight()){
		self.bitmap1.y=self.bitmap2.y;
		self.bitmap2.y=self.bitmap1.x+self.bitmap1.getHeight();
		self.bitmap3.y=self.bitmap1.y+self.bitmap1.getHeight()*2;
	}
}
function onframe(){
	background.run();
	if(stageSpeed-- < 0){
		stageSpeed=100;
		addstage();	
	}
	var key=null;
	for(key in stagelayer.childList){
		var _child=stagelayer.childList[key];
		_child.onframe();
	}
}
function Floor(){
	base(this,LSprite,[]);
	var self=this;
	self.hy=0;
	self.setView();	
};
Floor.prototype.setView=function(){};
function floor1(){
	base(this,Floor,[]);	
}
floor1.prototype.setView=function(){
	var self=this;
	self.bitmap=new LBitmapData(new LBitmapData(imglist["right"]));
	self.addChild(self.bitmap);	
}
function stageInit(){
	stagelayer=new LSprite();
	backlayer.addChild(stagelayer);	
}
function addstage(){
	var mstage;
	mstage=new floor1();
	mstage.y=480;
	msgage.x=Math.random()*280;
	stagelayer.addChild(msgage);	
}
Floor.prototype.onframe=function(){
	var self=this;
	self.y-=2;	
};
Floor.prototype.hitrun=function(){};
</script>
</body>
</html>
